package com.eas.task.web.common;

import java.io.FileReader;
import java.util.Properties;
import java.util.Map.Entry;

import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.webapp.WebAppContext;

public class EasTaskWebStarter {

    /**
     * Main.
     */
    public static void main(String[] args) throws Exception {
        Server server = new Server();

        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setPort(8092);
        server.addConnector(connector);

        WebAppContext context = new WebAppContext();

        context.setContextPath("/");
        context.setDescriptor("src/main/webapp/WEB-INF/web.xml");
        context.setResourceBase("src/main/webapp");

        server.setHandler(context);

        Properties p = new Properties();
        String userHome = System.getProperty("user.home");
        p.load(new FileReader(userHome + "\\app.properties"));
        for (Entry<Object, Object> entry : p.entrySet()) {
            System.setProperty((String) entry.getKey(), (String) entry.getValue());
        }

        server.start();
    }
}
